package com.lyf.design.practice.theory.behavior.strategy.sample;

import net.sf.cglib.core.internal.Function;

import java.util.Hashtable;

/**
 * @author LYF
 * @date 2022/6/22
 */
public class Tests {
    public static void main(String[] args) {
        Sale sale = new Sale();
        sale.setStrategy(child -> 1.0);// 加设 person child 为1.0
        System.out.println(sale.getPrize(new Child()));

        // 若 比较灵活 可考虑采用 函数式编程---
        sale.setStrategy(adult -> 2.0);// 加设 person child 为1.0
        System.out.println(sale.getPrize(new Adult()));

        ///Map<String, Function<k,v>> map = new Hashtable<>();
        sale.setStrategy(new ChildSaleStrategy());
        System.out.println(sale.getPrize(new Child()));
    }
}
